GH-50527: [C++] Remove ARROW_SSE4_2_FLAG for x86 MSVC#50526
Conversation
The SSE4.2 flag is invalid in for the MSVC x86 compiler. https://learn.microsoft.com/en-us/cpp/build/reference/arch-x86
|
Thanks for opening a pull request! If this is not a minor PR. Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose Opening GitHub issues ahead of time contributes to the Openness of the Apache Arrow project. Then could you also rename the pull request title in the following format? or See also: |
|
|
| # x86/amd64 compiler flags, msvc/gcc/clang | ||
| if(MSVC) | ||
| set(ARROW_SSE4_2_FLAG "/arch:SSE4.2") | ||
| set(ARROW_SSE4_2_FLAG "") |
There was a problem hiding this comment.
Can we do this only for x86 environment?
This disables SSE 4.2 on x64 environment too.
There was a problem hiding this comment.
SSE4.2 appears to behave identically for x64. The official Microsoft documentation lists SSE4.2 as valid flag for msvc-180, but the compiler begs to disagree. I am having trouble finding documentation to support this, but building with x64 does produce the same nuisance warnings as with x86. This appears to be because SSE2 and its extensions are implicitly targeted as the baseline. Here is the relevant usage line on my machine:
Command> "C:\Program Files\Microsoft Visual Studio\18\Professional\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe" /? 2>nul | findstr "arch:"
[Output]
/arch:<AVX|AVX2|AVX512> minimum CPU architecture requirements, one of:
Next week I will expand the scope of testing to see if there is any MSVC version that supports the SSE4.2 flag without warnings.
There was a problem hiding this comment.
Update: The flag is invalid for all "cl.exe" executables that ship with Visual Studio 2022 (VC17) and Visual Studio 2026 (VC18).
Valid flags for x86:
/arch:<IA32|SSE|SSE2|AVX|AVX2|AVX512>
Valid flags for x64:
/arch:<AVX|AVX2|AVX512>
There was a problem hiding this comment.
OK. Could you add a comment why we don't need /arch:SSE4.2 that is mentioned in the documented on both of x86 and x64?
The SSE4.2 flag is invalid for the MSVC x86 compiler, and ignored by x64 as an automatic extension of the default (SSE2).
https://learn.microsoft.com/en-us/cpp/build/reference/arch-x86
Rationale for this change
MSVC builds generate hundreds of nuisance warnings that resemble:
cl : Command line warning D9002 : ignoring unknown option '/arch:SSE4.2'
What changes are included in this PR?
Simple replacement of the MSVC-specific flag "/arch:SSE4.2" with an empty string. This matches a working configuration prior to ~July 2025, at which time the flag seems to have been edited while adding xsimd definitions below.
Are these changes tested?
Yes - using cmake version 3.29.6 and both the VC17 and VC18 compilers.
Are there any user-facing changes?
No. This only affects developers building the source code and has no impact on the Apache Arrow libraries.